package com.jin.webvideo.externalInterfaces.iqiyi;

import com.alibaba.fastjson.JSONObject;
import com.jin.webvideo.exception.UnavailableServiceException;
import com.jin.webvideo.util.sys.ClientUtil;
import com.jin.webvideo.util.base.StringUtil;

import java.io.*;

public class IQIYIUtil {
    public static final String HANDLE_SOURCE = "iqiyi";
    public static Result readResult(String url, int start, int end) throws UnavailableServiceException {
        Result result = new Result();
        try {
            String json = ClientUtil.httpGet(url);
            json = StringUtil.substringTrim(json, start);
            json = StringUtil.substringTrim(json, end);
            result = JSONObject.parseObject(json, Result.class);
        } catch (IOException e) {
            throw new UnavailableServiceException();
        }
        return result;
    }
    public static Result readResult(String url) throws UnavailableServiceException {
        return readResult(url, 0, 0);
    }
}
